package com.heo.service.impl;

import java.util.List;
import java.util.Map;

import com.github.pagehelper.Page;
import com.heo.dao.BaseMapper;
import com.heo.pojo.BaseEntity;
import com.heo.service.BaseService;
import com.heo.util.PageBean;

/**
 * 基础service实现类
 * @author penggl
 * @version 1.0
 * @date 2017-5-29
 */
public abstract class BaseServiceImpl<T extends BaseEntity> implements BaseService<T> {
	
	/**
	 * 获取dao
	 * @return
	 */
	protected abstract BaseMapper<T> getDao();

	@Override
	public List<T> listAll(){
		return getDao().listAll();
	}
	
	@Override
	public Page<T> listPageByEntity(PageBean pageBean, T entity) {
		return getDao().listPageByEntity(pageBean, entity);
	}

	@Override
	public Page<T> listPageByEntity(PageBean pageBean, T entity, String sqlId) {
		return getDao().listPageByEntity(pageBean, entity, sqlId);
	}

	@Override
	public Page<T> listPageByMap(PageBean pageBean, Map<String, Object> paramMap) {
		return getDao().listPageByMap(pageBean, paramMap);
	}

	@Override
	public Page<T> listPageByMap(PageBean pageBean, Map<String, Object> paramMap, String sqlId) {
		if(sqlId == null || sqlId.trim().equals("")){
			return null;
		}
		return getDao().listPageByMap(pageBean, paramMap, sqlId);
	}

	@Override
	public T insert(T t) {
		return getDao().insert(t);
	}

	@Override
	public long insertAll(List<T> list) {
		return getDao().insertAll(list);
	}

	@Override
	public long delete(T t) {
		return getDao().delete(t);
	}
	
	@Override
	public long deleteById(long id) {
		return getDao().deleteById(id);
	}

	@Override
	public long deleteByMap(Map<String, Object> paramMap, String sqlId) {
		return getDao().deleteByMap(paramMap, sqlId);
	}

	@Override
	public long update(T t) {
		return getDao().update(t);
	}

	@Override
	public long updateByMap(Map<String, Object> paramMap, String sqlId){
		return getDao().updateByMap(paramMap, sqlId);
	}
	
	@Override
	public T getByKey(Object key) {
		return getDao().getByKey(key);
	}

	@Override
	public T getByEntity(T t) {
		return getDao().getByEntity(t);
	}

	@Override
	public T getByEntity(T t, String sqlId) {
		return getDao().getByEntity(t, sqlId);
	}
	
	@Override
	public T getByMap(Map<String, Object> paramMap){
		return getDao().getByMap(paramMap);
	}
	
	@Override
	public T getByMap(Map<String, Object> paramMap, String sqlId){
		return getDao().getByMap(paramMap, sqlId);
	}

	@Override
	public List<T> listByEntity(T t) {
		return getDao().listByEntity(t);
	}

	@Override
	public List<T> listByEntity(T t, String sqlId) {
		return getDao().listByEntity(t, sqlId);
	}

	@Override
	public List<T> listByMap(Map<String, Object> paramMap) {
		return getDao().listByMap(paramMap);
	}

	@Override
	public List<T> listByMap(Map<String, Object> paramMap, String sqlId) {
		return getDao().listByMap(paramMap, sqlId);
	}

}
